package com.my.test.jdbc;

import javax.sql.DataSource;
import java.io.PrintWriter;
import java.sql.*;
import java.util.logging.Logger;

/**
 * Created by Administrator on 2017/8/1.
 */
public class abstractDataSource implements DataSource{

    private int maxActive;
    private long maxWaiteTime;
    private String url;
    private String userName;
    private String pwd;
    private String drive;


    private Driver _driver;
    @Override
    public Connection getConnection() throws SQLException {
        return null;
    }

    @Override
    public Connection getConnection(String username, String password) throws SQLException {
        return null;
    }

    @Override
    public <T> T unwrap(Class<T> iface) throws SQLException {
        return null;
    }

    @Override
    public boolean isWrapperFor(Class<?> iface) throws SQLException {
        return false;
    }

    @Override
    public PrintWriter getLogWriter() throws SQLException {
        return null;
    }

    @Override
    public void setLogWriter(PrintWriter out) throws SQLException {

    }

    @Override
    public void setLoginTimeout(int seconds) throws SQLException {

    }

    @Override
    public int getLoginTimeout() throws SQLException {
        return 0;
    }

//    @Override
    public Logger getParentLogger() throws SQLFeatureNotSupportedException {
        return null;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPwd() {
        return pwd;
    }

    public void setPwd(String pwd) {
        this.pwd = pwd;
    }

    public String getDrive() {
        return drive;
    }

    public void setDrive(String drive) {
        this.drive = drive;
    }


    class ConnectionPoolFactory{

        private String url;
        private String userName;
        private String pwd;
        private String drive;
        private Driver _driver;
        public Connection createConnection(){
            try {
                Class.forName("");
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }

            java.util.Properties info = new java.util.Properties();
            info.setProperty("",userName);
            info.setProperty("",pwd);
            try {
                _driver = DriverManager.getDriver(url);
                return _driver.connect(url,info);
            } catch (SQLException e) {
                e.printStackTrace();
            }
            return null;
        }
    }
}
